using System.Data.Entity.ModelConfiguration;
using CodeSaude.Domain.Entities;

namespace CodeSaude.Infrastructure.Data.EntityConfig
{
    public class PermissaoMap : EntityTypeConfiguration<Permissao>
    {
        public PermissaoMap()
        {
            // Primary Key
            HasKey(t => t.PermissaoId);

            // Properties
            // Table & Column Mappings
            ToTable("permissao");
            Property(t => t.PermissaoId).HasColumnName("id_permissao");
            Property(t => t.IdMenu).HasColumnName("id_menu");
            Property(t => t.Incluir).HasColumnName("incluir");
            Property(t => t.Alterar).HasColumnName("alterar");
            Property(t => t.Excluir).HasColumnName("excluir");

            // Relationships
            HasRequired(t => t.Menu)
                .WithMany(t => t.Permissoes)
                .HasForeignKey(d => d.IdMenu);
        }
    }
}
